package GiaoHangVietNam.Entities;

import java.io.Serializable;
import java.util.ArrayList;

import android.util.Log;

import com.google.android.gms.common.data.f;

// Chi tiết đơn hàng
public class InvoiceDetails implements Serializable {
	// ID đơn hàng
	public int ID;
	public String CompanyName;
	
	public String Name;
	public String Address;
	public double Lat;
	public double Lng;
	public String Number;
	public Boolean IsSending = false;
	// Đánh dấu đã gọi cho khách hàng chưa
	public Boolean IsCalled = false;
	public Boolean IsFinish = false;
	public Boolean IsWaiting = false;
	public ArrayList<GoodsInfor> ListGoods = new ArrayList<GoodsInfor>();
	// Đơn hàng thuộc vùng nào
	public short RegionID;

	public InvoiceDetails() {
	}
	 
	// 1,1,Tiếnnt,01688514498,Giày,500,20,16 ho tung mau,21.037964,105.773823,1
	public InvoiceDetails(String[] fields) {
		if (fields.length == 10) { 
			ID = Integer.parseInt(fields[1]);
			CompanyName=fields[2];
			Name = fields[3];
			Number = fields[4];
			Address = fields[5];
			Lat = Double.parseDouble(fields[6]);
			Lng = Double.parseDouble(fields[7]);
			 
			if (Integer.parseInt(fields[8]) == 1) {
				IsSending = true;
			} else {
				IsSending = false;

			}
				
			ListGoods = new ArrayList<GoodsInfor>();

			String[] strGoodsInfor = fields[9].split("-");
			if (strGoodsInfor.length > 0) {
				
				for (int i = 0; i < strGoodsInfor.length; i++) {
					GoodsInfor tmpGood = new GoodsInfor(strGoodsInfor[i]);
					ListGoods.add(tmpGood);
				}
			}
		}
	}
	public InvoiceDetails(InvoiceDetails other) {
		this.ID = other.ID;
		this.Name = other.Name;
		this.CompanyName = other.CompanyName;
		this.Address = other.Address;
		this.Lat = other.Lat;
		this.Lng = other.Lng;
		this.Number = other.Number;
		this.IsSending= other.IsSending;
		this.IsFinish = other.IsFinish;
		this.IsWaiting = other.IsWaiting;
		
		ListGoods = new ArrayList<GoodsInfor>();
		for(int i=0;i< other.ListGoods.size();i++)
		{
			ListGoods.add(new GoodsInfor(other.ListGoods.get(i)));
		}
	}
	public void AppendGoods(GoodsInfor newGoods)
	{
		ListGoods.add(newGoods);
	}
}
